package com.sosee.cgfw.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.sosee.cgfw.R;
import com.sosee.cgfw.adapter.InvitationAdapter;
import com.sosee.cgfw.interfac.InvitationInterface;
import com.sosee.cgfw.utils.Utils;
import com.lidroid.xutils.HttpUtils;
import com.umeng.analytics.MobclickAgent;

/**
 * Created by Thinkpad on 2016/2/24.
 * //申请邀请函 activity
 */
public class ApplyActivity extends Activity implements InvitationInterface {
    private ListView lv;
    private InvitationAdapter mAdapter;
    private HttpUtils httpUtils;

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply);
        initView();
    }
    public void initView(){
        httpUtils=new HttpUtils();
        lv= (ListView) findViewById(R.id.lv);
        mAdapter=new InvitationAdapter(this);
        mAdapter.setAnInterface(this);
        mAdapter.setStatus(1);//设置申请状态
        mAdapter.setList(Utils.shenQingList);
        lv.setAdapter(mAdapter);
    }


    @Override
    public void onClick(String showID) {
//        if(!showID.equals("-1")){
//            httpUtils.send(HttpRequest.HttpMethod.GET, Constans.APPLY_URL + showID, new RequestCallBack<String>() {
//                @Override
//                public void onSuccess(ResponseInfo<String> responseInfo) {
//                    JSONObject json=null;
//                    try {
//                        json=new JSONObject(responseInfo.result);
//                        String status=json.getString("status");
//                        if("success".equals(status)){
//                            String msg=json.getString("msg");
//                            Utils.showToast(msg);
//                        }else{
//                            String error=json.getString("error");
//                            Utils.showToast(error);
//                        }
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    }
//                }
//
//                @Override
//                public void onFailure(HttpException e, String s) {
//                    Utils.showToast("网络异常，再次申请失败");
//                }
//            });
//        }
    }

    public void back(View view){
        startActivity(new Intent(this,AssistantActivity.class));
        finish();
    }

    @Override
    public void onBackPressed() {
        startActivity(new Intent(this,AssistantActivity.class));
        finish();
    }
}
